<?php 
    header("Content-type: text/html; charset=utf-8");

	require_once('dbconnect.inc.php');
	require_once('auth.inc.php');	

	$redir = $_GET['redir'];

	if (!empty($_POST))
	{
		$redir = $_POST['redir'];

		$auth = new auth();

		if ($auth->authentication($dbh,$_POST))
		{
			$auth->setDefRedir($redir);

			header($auth->getRedir());

			$cookie = $auth->getCookie();
			setcookie($cookie['name'], $cookie['value']);
			
			exit();
		}
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=8" />
	<link rel="stylesheet" type="text/css" media="screen" href="css/asud.css" />
</head>

<body id="auth">
<div id="login">
<form method="post" name="loginForm" id="loginForm">
	<table id="form-table">
		<tr><td colspan="2" id="form-text">Вход в АСУД.</td></tr>
	    <tr><td id="form-name">Логин</td><td id="form-item"><input type="text" name="login" id="input-login"></td></tr>
		<tr><td id="form-name">Пароль</td><td id="form-item"><input type="password" name="password" id="input-password"></td></tr>
		<tr><td colspan="2" id="form-submit"><input type="submit" name="submit" value="Войти"></td></tr>
	</table>
	<input type="hidden" name="redir" value="<?php print($redir)?>">
</form>
</div>

</body>
</html>
